package cn.edu.neusoft.maxingxin231.yuejian06.Adapter;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;

import com.squareup.picasso.Picasso;

import java.util.List;

import cn.edu.neusoft.maxingxin231.yuejian06.Activity.DetailActivity;
import cn.edu.neusoft.maxingxin231.yuejian06.Activity.MasterDetailActivity;
import cn.edu.neusoft.maxingxin231.yuejian06.Activity.RecentRaceDetailActivity;
import cn.edu.neusoft.maxingxin231.yuejian06.Bean.MasterBean;
import cn.edu.neusoft.maxingxin231.yuejian06.Bean.RecentRaceBean;

public class RecentRaceAdapter extends Base2Adapter<RecentRaceBean> {
    public RecentRaceAdapter(Context context, List<RecentRaceBean> items, int layoutResource) {
        super(context, items, layoutResource);
    }
    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        RecentRaceBean recentRaceBean = items.get(position);
        if(recentRaceBean ==null) return;
        final ClubViewHolder clubViewHolder = (ClubViewHolder) holder;

        final String match_name=items.get(position).getMatch_name();
        final String match_phone=items.get(position).getMatch_phone();
        final String match_id=items.get(position).getMatch_id();
        final String match_address=items.get(position).getMatch_address();
        final String match_pic=items.get(position).getMatch_pic();

        clubViewHolder.c_tv1.setText(match_name);
        clubViewHolder.c_tv2.setText(match_phone);
        Picasso.with(context).load("http://10.0.2.2:80/yuejian14/public/static/match_img/"+items.get(position).getMatch_pic()).into(clubViewHolder.c_img1);
//<img width="250" height="150" class="picture-thumb" src="/yuejian14/public/static/match_img/5b9211a564486.jpg">
        clubViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //条目点击事件
                Log.i("TEST","onClick");
                Intent intent = new Intent(context,RecentRaceDetailActivity.class);
                intent.putExtra("match_name",match_name);
                intent.putExtra("match_phone",match_phone);
                intent.putExtra("match_id",match_id);
                intent.putExtra("match_address",match_address);
                intent.putExtra("match_pic",match_pic);
                context.startActivity(intent);
            }
        });
    }
    public void setList(List<RecentRaceBean> list){
        this.items = list;
        notifyDataSetChanged();
    }
}
